package bitCalculation;

public class SingleNumberiii260 {
    public int[] singleNumber(int[] nums) {
        int temp = 0;
        for (int i = 0; i < nums.length; i++) {
            temp = temp ^ nums[i];
        }
        int[] result = new int[2];
        int x = 1;
        while ((temp & x) != x) {
            x = x << 1;
        }
        for (int i = 0; i < nums.length; i++) {
            if((nums[i]&x)==0){
                result[0] = result[0]^nums[i];
            }else {
                result[1] = result[1]^nums[i];
            }
        }

        return result;
    }
}
